<admintpl file="header" />
<style>
    .uploadList ul li{
        list-style: none;
    }
    .uploadList ul li img{
        max-height: 90px;
    }
</style>
<script type="text/javascript" src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
<link rel="stylesheet" href="__PUBLIC__/uploadify/uploadify.css">
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li ><a href="{:U('Advertise/index')}"> 广告列表 </a></li>
        <li class="active"><a href="{:U('Advertise/add')}">添加广告</a></li>
    </ul>
    <form action="{:U('Advertise/add')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data">
        <fieldset>
            <div class="control-group">
                <label class="control-label"> 标题 </label>
                <div class="controls">
                    <input type="text" name="ad_name" placeholder="请输入标题">
                    <span class="form-required">*</span>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"> 描述 </label>
                <div class="controls">
                    <textarea name="ad_content" style="width: 618px;height: 60px;resize: none" placeholder="请输入简单描述"></textarea>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"> 图 (600px * 320px) </label>
                <div class="controls">
                    <div lab="uploadFile">

                        <input id="di_card_back" type="file" multiple="false">
                        <script type="text/javascript">
                            $(function() {
                                var path2 = "{$data['path']}";
                                $('#di_card_back').uploadify({
                                    'formData'    : {          //POST数据
                                        '<?php echo session_name();?>' : '<?php echo session_id();?>',
                                    },
                                    'fileTypeDesc' : '上传文件',//上传描述
                                    'fileTypeExts' : '*.jpeg;,*.jpg;*.png,*.JPEG;,*.JPG;*.PNG',
                                    'swf'      : '__PUBLIC__/uploadify/uploadify.swf',
                                    'uploader' : "{:U('User/File/upload')}",
                                    'buttonText':'选择文件',
                                    'fileSizeLimit' : '2048KB',
                                    'uploadLimit' : 1,//上传文件数
                                    'width':90,
                                    'height':36,
                                    'successTimeout':10,//等待服务器响应时间
                                    'removeTimeout' : 0.2,//成功显示时间
                                    'onUploadSuccess' : function(file, data, response) {
                                        //转为json
                                        data=$.parseJSON(data);
                                        //获得图片地址
                                        var imageUrl = data.url;
                                        var li="<li path='"+data.path+"' url='"+data.url+"'><img src='__ROOT__"+imageUrl+"'/><input type='hidden' name='path' value='"+imageUrl+"'/></li>";
                                        $("#uploadLogoBack ul").html(li);
                                    }
                                });
                            });
                        </script>
                        <div id="uploadLogoBack" class="uploadList">
                            <ul>
                                <li path="{$data[path]}" url="{$data['path']}"><img src="{$data[path]}"/><input type='hidden' name='path' value="{$data[path]}"/></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
        <div class="form-actions">
            <button class="btn btn-primary js-ajax-submit" type="submit">{:L("ADD")}</button>
            <a class="btn" href="javascript:history.back(-1);">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
</body>
</html>